package thread.pipedthread;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;

public class ReadThread extends Thread{
	PipedInputStream pi = new PipedInputStream();
	public ReadThread(PipedInputStream pi){
		this.pi=pi;
	}
	public void run() {
		char []  ch = new char[10];
		try {
			BufferedReader br = new BufferedReader(new InputStreamReader(pi,"utf-8"));
			int i =0;
			while((i=br.read(ch))!=-1){
				System.out.print(new String(ch));
			}
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			try {
				pi.close();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		
	}
}
